package com.chanjiedata.changbs.module.mine;

/**
 * 文件名 : TiXianMessageDetailActivity
 * 创建者 : MangoWang
 * 创建日期 : 2019/11/28 17:57
 * 微信 : MangoWaWang
 * 邮箱 : 763482205@qq.com
 * 描述 : TODO
 */

import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

import com.chanjiedata.changbs.R;
import com.chanjiedata.changbs.base.BaseActivity;
import com.chanjiedata.changbs.net.Apis;
import com.chanjiedata.changbs.net.NetworkManager;
import com.chanjiedata.changbs.net.interfaces.OnRequestCallBack;
import com.chanjiedata.changbs.proto.MemberOuterClass;
import com.chanjiedata.changbs.utlis.StatusBarUtil;
import com.google.protobuf.InvalidProtocolBufferException;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TiXianMessageDetailActivity extends BaseActivity {


    @BindView(R.id.back_tv)
    TextView backTv;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_big_money)
    TextView tvBigMoney;
    @BindView(R.id.tv_status)
    TextView tvStatus;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.tv_service_charge)
    TextView tvServiceCharge;
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_get_time)
    TextView tvGetTime;
    @BindView(R.id.tv_bank_name)
    TextView tvBankName;
    @BindView(R.id.tv_charge_number)
    TextView tvChargeNumber;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ti_xian_message_detail);
        StatusBarUtil.setStatusBarLightMode(this, Color.parseColor("#ffffff"), true);
        ButterKnife.bind(this);
        initData();
        initListener();


    }

    private void initListener() {
        backTv.setOnClickListener(view -> finish());
    }

    private void initData() {
        tvTitle.setText("账单详情");
        MemberOuterClass.Pd_cash_info.Builder builder =  MemberOuterClass.Pd_cash_info.newBuilder();
        builder.setPdcId(getIntent().getStringExtra("pdc_id"));

        NetworkManager.INSTANCE.post(Apis.pd_cash_info, builder.build().toByteArray(), new OnRequestCallBack() {
            @Override
            public void onOk(byte[] response) throws InvalidProtocolBufferException {
                hideProgress();
                MemberOuterClass.Pd_cash_info tiXianDetail =  MemberOuterClass.Pd_cash_info.parseFrom(response);
                tvBigMoney.setText("¥" + tiXianDetail.getPdcAmount());
                tvStatus.setText(tiXianDetail.getPdcPaymentState());
                tvMoney.setText("¥" + tiXianDetail.getPdcAmount());
                tvServiceCharge.setText("¥" +tiXianDetail.getPdcPoundage());
                tvTime.setText(tiXianDetail.getPdcAddtime());
                tvGetTime.setText(tiXianDetail.getPdcPaymentTime());
                tvBankName.setText(tiXianDetail.getPdcBankName());
                tvChargeNumber.setText(tiXianDetail.getPdcSn());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                hideProgress();
                showToast(errorMessage);
            }
        });
    }
}
